<?php

namespace app\payment\validate;

use think\Validate;

/**
 * 收款验证器
 */
class Collection extends Validate {

    //定义验证规则
    protected $rule = [
        'merchant_id|商户号' => 'require|number',
        // 'out_name|付款人姓名' => 'require',
        // 'out_card|付款银行卡' => 'require',
        // 'enter_name|收款人姓名' => 'require',
        // 'enter_card|收款银行卡' => 'require',
        'cash|金额' => 'require|float|egt:0.01',
        'remark|本地备注' => '',
        'status|付款状态' => '',
        'order_id|本地订单号' => '',
        'other_order_id|第三方订单号' => 'length:1,50',
        'programmer_remark|程序员备注' => '',
    ];
    //定义验证提示
    protected $message = [
        'other_order_id' => '第三方订单号不能为空',
    ];
    //定义验证场景
    protected $scene = [
        'edit' => ['other_order_id' => 'requireIf:status,1|length:1,50'],
    ];

    // 验证场景定义
    public function sceneEdit() {
        return $this->only(['other_order_id'])
                        ->append('other_order_id', 'requireIf:status,1|length:1,50');
    }

}
